<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>文化-历史文化管理</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <meta name="keywords" content="历史文化管理">
    <meta name="author" content="yinqi">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="/css/style.min.css" rel="stylesheet">
    <style>
        table{
            table-layout:fixed;
        }

        td{
            overflow:hidden;
            text-overflow:ellipsis;
            white-space:nowrap;
        }
    </style>
</head>
<body>
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-header"><h4>文化-历史文化管理</h4></div>
            <div class="card-toolbar clearfix">
                <form class="pull-right search-bar" action='/history/getAllMyHistory' id="form3" method='post' role="form">
                    <input type="hidden" name="page" id="pageNo" th:value="${page}">
                    <table>
                        <tr>

                            <td th:width="300px">
                                <select class="form-control" id="desc" name="cid" size="1" >
                                    <option value="0" th:selected="${queryObj.cid==0}">默认顺序</option>
                                    <option value="1" th:selected="${queryObj.cid==1}">最新排序</option>
                                    <option value="2" th:selected="${queryObj.cid==2}">最早排序</option>
                                </select>
                            </td>
                            <td th:width="30px"> </td>

                            <td th:width="500px">
                                <div class="input-group">
                                    <input type="text" class="form-control" th:value="${queryObj.getKeyword()}"
                                           name="keyword" placeholder="请输入标题名称">
                                    <span class="input-group-btn">
                          <button class="btn btn-default" type="submit">查询</button></span>
                                </div>
                            </td>
                        </tr>
                        <!--								<input type="hidden" name="search_field" id="search-field" value="title">-->


                    </table>
                </form>
                <div class="toolbar-btn-action">
                    <a class="btn btn-danger" href="javascript:delCus()" id="delCus"><i class="mdi mdi-window-close"></i> 删除</a>
                </div>
        </div>
            <div class="card-body">
                <form name="form2" id="fm3" action="/history" method="post">
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th>
                                    <label class="lyear-checkbox checkbox-primary">
                                        <input type="checkbox" id="check-all" ><span></span>
                                    </label>
                                </th>
                                <th>序号</th>
                                <th>历史文化标题</th>
                                <th>历史内容</th>
                                <th>发布作者</th>
                                <th>发布时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="history : ${historyPage.getRecords()}">

                                <td>
                                    <label class="lyear-checkbox checkbox-primary">
                                        <input type="checkbox" name="historyId" th:value="${history.historyId}"><span></span>
                                    </label>
                                </td>
                                <td th:text="${historyStat.count}">1</td>
                                <td th:text="${history.historyTittle}"></td>
                                <!--<td><img th:src="${tou.touImg}" alt="没有头像" width="20px" height="20px"></td>-->
                                <td style="width:80px" th:text="${history.historyContent}">《倚天屠龙记》</td>

                                <td th:text="${history.tbTou.name}">36</td>
                                <td th:text="${#temporals.format(history.historyTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                <td>
                                    <div class="btn-group btn-group-sm">
                                        <a class="btn btn-info" th:onclick="'javascript:getHistoryById('+${history.historyId}+')'"  title="编辑" ><i class="mdi mdi-pencil"></i></a>
                                        <a class="btn  btn-danger" th:href="@{'/history/delHistoryById?historyId='+${history.historyId}}" title="删除" ><i class="mdi mdi-window-close"></i></a>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </form>
                <div class="pagination">

                    <div id="myPage"></div>
                    <link rel="stylesheet" type="text/css" href="/js/page/jquery.sPage.css">
                    <script type="text/javascript"
                            src="/js/jquery.min.js"></script>
                    <script type="text/javascript"
                            src="/js/page/jquery.sPage.min.js"></script>
                    <script type="text/javascript" th:inline="javascript">
                        //初始化分页组件

                        $("#myPage").sPage({

                            page:[[${page}]],//当前页码，必填
                            total:[[${historyPage.getTotal()}]],//数据总条数，必填
                            pageSize:[[${historyPage.getSize()}]],//每页显示多少条数据，默认10条
                            totalTxt:"共"+[[${historyPage.getTotal()}]]+"条",//数据总条数文字描述，{total}为占位符，默认"共{total}条"
                            showTotal:true,//是否显示总条数，默认关闭：false
                            showSkip:true,//是否显示跳页，默认关闭：false
                            showPN:true,//是否显示上下翻页，默认开启：true
                            prevPage:"上一页",//上翻页文字描述，默认“上一页”
                            nextPage:"下一页",//下翻页文字描述，默认“下一页”
                            backFun:function(page){
                                //点击分页按钮回调函数，返回当前页码
                                console.log(page);
                                $("#pageNo").val(page);
                                $("#form3").submit();
                            }
                        });

                        //回调方法:点击上一页和下一页
                        function handlePaginationClick(new_page_index, pagination_container) {
                            $("#pageNo").val(new_page_index + 1);
                            $("#form3").submit();
                        }

                        $(function () {
                            $("#check-all").click(function () {
                                if(this.checked){
                                    $("input[name=historyId]").prop("checked",true);
                                }
                                else {
                                    $("input[name=historyId]").prop("checked",false);
                                }

                            });
                            $("#checkrev").click(function () {
                                $("input[name=historyId]").each(function () {
                                    $(this).prop("checked",!$(this).prop("checked"))
                                });
                            })
                        });

                        function getHistoryById(historyId) {
                            location.href="/history/getHistoryById?historyId="+historyId;
                        }

                        function lookHistoryById(historyId) {
                            location.href="/history/lookHistoryById?historyId="+historyId;
                        }

                        function delCus() {
                            $("#fm3").prop("action","/history/delHistoryById");
                            var len=$("input[name=historyId]:checked").length;
                            if(len>0){
                                if(confirm("将要删除你的所有信息?")){
                                    $("#fm3").submit();
                                }
                            }else {
                                alert("你还没有选中")
                            }
                        }
                        function exp() {
                            $("#fm3").prop("action","tou/expexl");
                            var len=$("input[name=historyId]:checked").length;
                            if(len>0){
                                if(confirm("是否要生成表格")){
                                    $("#fm3").submit();
                                }
                            }else {
                                alert("你还没有选中")
                            }
                        }
                    </script>

                </div>

            </div>
            </div>
    </div>
</div>
</div>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="/js/main.min.js"></script>
</body>
</html>